package com.app.micaihu.view.home.exclusive.adapter

import com.app.micaihu.bean.news.NewsEntity
import com.app.micaihu.configure.TypeConstant
import com.app.micaihu.view.home.exclusive.adapter.provider.AdToutiaoProvider
import com.app.micaihu.view.home.exclusive.adapter.provider.DefaultItemProvider
import com.app.micaihu.view.home.exclusive.adapter.provider.OneBigImageItemProvider
import com.app.micaihu.view.home.exclusive.adapter.provider.VideoItemProvider
import com.chad.library.adapter.base.BaseProviderMultiAdapter
import com.chad.library.adapter.base.module.LoadMoreModule

/**
 * 独家
 */
class ExclusiveListAdapter : BaseProviderMultiAdapter<NewsEntity>(), LoadMoreModule {

    companion object {
        const val itemTypeOneBigImage = 1// 独家 大图
        const val itemTypeVideo = 2// 独家 视频
        const val itemTypeToutiao = 3//广告
        const val itemType0 = 0
    }

    init {
        addItemProvider(OneBigImageItemProvider())
        addItemProvider(VideoItemProvider())
        addItemProvider(AdToutiaoProvider())
        addItemProvider(DefaultItemProvider())
    }

    override fun getItemType(data: List<NewsEntity>, position: Int): Int {
        val item = data[position]
        if (item.nativeAd != null) return itemTypeToutiao
        return when (item.articleType) {
            TypeConstant.EXCLUSIVE_NEWS_BIG_IMAGE -> itemTypeOneBigImage
            TypeConstant.EXCLUSIVE_NEWS_VIDEO -> itemTypeVideo
            else -> itemType0
        }
    }


}